﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;

namespace Model
{
    [DataContract]
    public class Booking
    {
        [DataMember]
        private Show show;
        [DataMember]
        private Customer customer;
        [DataMember]
        private List<Ticket> tickets;
        [DataMember]
        private int reservation;

        public Booking()
        {
            show = null;
            customer = null;
            tickets = new List<Ticket>();
            reservation = 0;
        }

        public Booking(Show show, Customer customer, List<Ticket> tickets, int reservation)
        {
            this.show = show;
            this.customer = customer;
            this.tickets = tickets;
            this.reservation = reservation;
        }

        public Show Show
        {
            get { return show; }
            set { show = value; }
        }
        public Customer Customer
        {
            get { return customer; }
            set { customer = value; }
        }

        public int Reservation
        {
            get { return reservation; }
            set { reservation = value; }
        }

        public List<Ticket> Tickets
        {
            get { return tickets; }
            set { tickets = value; }
        }

        private string GetSeatIds()
        {
            string seatIds = "";
            foreach(Ticket ticketObj in tickets)
            {
                seatIds = seatIds + ticketObj.Seat.SeatId + " ";
            }

            return seatIds;
        }

        public override string ToString()
        {
            string payed = "Nej";
            if(Reservation == 0)
            {
                payed = "Ja";
            }

            return "Dato: " + Show.DateTimeStart + "     Film: " + show.ThisMovie.Title + "     Sal: " + show.CinemaHall.Name + "     Betalt: " + payed + "     Sæder: " + GetSeatIds();
        }

    }
}
